#ifndef VENUS_SHAPES_TRIANGLE_H
#define VENUS_SHAPES_TRIANGLE_H

#include "common/venus.h"
#include "shape.h"
#include "triangle_mesh.h"

namespace venus {
class Triangle : public Shape {
 public:		
  Triangle(TriangleMesh *mesh, const int *vertex_indices)
      : mesh_(mesh), vertex_indices_(vertex_indices) {
  }

  virtual int Intersect(const Ray &ray, float *tHit, 
                        DifferentialGeometry *dg) const;
  virtual int Intersect(const Ray &ray) const;
  virtual AABB Bound() const;

  const Point &point(int i) const { 
    return mesh_->point(vertex_indices_[i]);
  }
  const Normal &normal(int i) const {
    return mesh_->normal(vertex_indices_[i]);
  }

private:
  const SharedPtr<TriangleMesh> mesh_;
  const int *vertex_indices_;
};
}//namespace venus

#endif
